﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace Core
{
    class WorkerThread
    {
        //public delegate void Finished(object sender, EventArgs e);
        public event EventHandler Finished;

        public Worker worker { get; private set; }
        public Thread thread { get; private set; }

        public WorkerThread(Worker worker, Thread thread)
        {
            this.worker = worker;
            this.thread = thread;
        }

        public void Start()
        {
            thread.Start();
            thread.Join();
            if (Finished != null)
                Finished(this, null);
        }

        public bool IsActive()
        {
            if (thread.ThreadState == ThreadState.Stopped)
                return false;
            return true;
        }
    }
}
